home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / fixptlib / realloc_fp_data.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-18  |  1.8 KB  |  76 lines

  1. realloc_fp_data(n)
  2. int n;
  3. {
  4.     int i,j,*it;
  5.     double *vt,**mt,***tmt;
  6.     extern int stop,var_dim,*fp_period;
  7.     extern double **fp_x,***fp_eval,***fp_evec,*fp_xerr;
  8.     
  9.     it = (int *) realloc(fp_period,(unsigned) n * sizeof(int));
  10.     if (!it){
  11.         system_mess_proc(1,"fp allocation failure!");
  12.         stop = 1;
  13.         return;
  14.     }
  15.     fp_period = it;
  16.     vt = (double *) realloc(fp_xerr,(unsigned) n * sizeof(double));
  17.     if (!vt){
  18.         system_mess_proc(1,"fp allocation failure!");
  19.         stop = 1;
  20.         return;
  21.     }
  22.     fp_xerr = vt;
  23.     
  24.     mt = (double **) malloc((unsigned) sizeof(double *) * var_dim);
  25.     /* reallocate memory for coords */
  26.     for(i=0;i<var_dim;i++){
  27.         mt[i] = (double *) realloc(fp_x[i],(unsigned) sizeof(double) * n);
  28.         if(!mt[i]){
  29.             system_mess_proc(1,"realloc_memory: m allocation failure!!!");
  30.             stop=1;
  31.             return;
  32.         }
  33.     }
  34.     fp_x = mt;
  35.     free(mt);
  36.  
  37.     tmt = (double ***) malloc((unsigned) sizeof(double **) * var_dim);
  38.     for(i=0;i<var_dim;i++){
  39.         tmt[i] = (double **) malloc((unsigned) sizeof(double *) * 2);
  40.         if(!tmt[i]){
  41.             system_mess_proc(1,"realloc_memory: m allocation failure!!!");
  42.             stop=1;
  43.             return;
  44.         }
  45.         for(j=0;j<2;j++){
  46.             tmt[i][j] = (double *) realloc(fp_eval[i][j],(unsigned) sizeof(double) * n);
  47.             if(!tmt[i][j]){
  48.                 system_mess_proc(1,"realloc_memory: m allocation failure!!!");
  49.                 stop=1;
  50.                 return;
  51.             }
  52.         }
  53.     }
  54.     fp_eval = tmt;
  55.     free(tmt);
  56.     tmt = (double ***) malloc((unsigned) sizeof(double **) * var_dim);
  57.     for(i=0;i<var_dim;i++){
  58.         tmt[i] = (double **) malloc((unsigned) sizeof(double *) * var_dim);
  59.         if(!tmt[i]){
  60.             system_mess_proc(1,"realloc_memory: m allocation failure!!!");
  61.             stop=1;
  62.             return;
  63.         }
  64.         for(j=0;j<var_dim;j++){
  65.             tmt[i][j] = (double *) realloc(fp_evec[i][j],(unsigned) sizeof(double) * n);
  66.             if(!tmt[i][j]){
  67.                 system_mess_proc(1,"realloc_memory: m allocation failure!!!");
  68.                 stop=1;
  69.                 return;
  70.             }
  71.         }
  72.     }
  73.     fp_eval = tmt;
  74.     free(tmt);
  75. }
  76.